
class LogIn {
    private String userName = "admin";
    private String passWord = "123456";

    public void logIn(String userName, String passWord) throws UserNameException, PassWordException {

            if (!this.userName.equals(userName)) {
                throw new UserNameException("登录密码错误!");
            }

            if (!this.passWord.equals(passWord)) {
                throw new PassWordException("登录密码错误!");
            }
        }
}
public class Test {
    public static void main(String[] args) {
        try {
            LogIn logIn = new LogIn();
            logIn.logIn("admin2","1234567");
        }catch (UserNameException e) {
            e.printStackTrace();
            System.out.println("捕捉到了用户名错误异常.......");
        }catch (PassWordException e) {
            e.printStackTrace();
            System.out.println("捕捉到了用户密码错误异常.......");
        }
        System.out.println("程序继续执行");
    }
}
